<template>
	<view class="mainbgc">
		<!-- 赠品列表 -->
		<header-top :messageInfo="{typeFlag:true,message:'促销商品',liner:false}"></header-top>

		<view class="mainpadding2">
			<!-- <view class="flexbetween">
				<input class="input-text" type="text" placeholder="请输入商品名称" v-model="keywords">
				<view class="sousuo" @click="getList">搜索</view>
			</view>
			 -->
			<view class="mainpadding_top ffffff radius" v-for="(item,index) in list" :key="index" @click="checkgoods(item)">
				<view class="flexbetween">
					<view class="titletext" style="color: #ff0000;">截至日期：{{item.end_time_text}}</view>
					<u-icon name="arrow-right" size="16" color="#999"></u-icon>
				</view>
				<view class="flexbetween bottom-line bottom-padding margin_top">
					<!-- 已勾选 -->
					<!-- <view class="Vector" v-show="item.is_check"></view> -->
					<!-- 未勾选 -->
					<!-- <view class="Vectorhuse" v-show="!item.is_check"></view> -->
					<view class="titletext">{{item.name}}</view>
					<!-- <view class="titletext margin_left2" style="color: #0BBDCB;">选择</view> -->
				</view>
				<view class="bottom-line bottom-padding">
					<view class="" v-for="ite in item.activitygoods" :key="ite.activity_id">
						<view class="flexbetween margin_top" >
							<view class="nostrongtext">{{ite.goods.name}}
							<text class="xiaohuang" v-if="ite.goods_type==2">（赠品）</text></view>
							<!-- 大单位 -->
							<view class="nostrongtext" v-show="ite.join_goods_unit==1">数量：{{ite.num}}/{{ite.goods.biggoodsunit.name}}</view>
							<!-- 中单位 -->
							<view class="nostrongtext" v-show="ite.join_goods_unit==2">数量：{{ite.num}}/{{ite.goods.middlegoodsunit.name}}</view>
							<!-- 小单位 -->
							<view class="nostrongtext" v-show="ite.join_goods_unit==3">数量：{{ite.num}}/{{ite.goods.smallgoodsunit.name}}</view>
						</view>
						<!-- 大单位 -->
						<view class="xiaolan margin_top1" v-show="ite.join_goods_unit==1">单价：{{ite.price}}/{{ite.goods.biggoodsunit.name}}</view>
						<!-- 中单位 -->
						<view class="xiaolan margin_top1" v-show="ite.join_goods_unit==2">单价：{{ite.price}}/{{ite.goods.middlegoodsunit.name}}</view>
						<!-- 小单位 -->
						<view class="xiaolan margin_top1" v-show="ite.join_goods_unit==3">单价：{{ite.price}}/{{ite.goods.smallgoodsunit.name}}</view>
					</view>
					
				</view>
				<view class="nostrongtext margin_top">
					备注：{{item.notes}}
				</view>
				<view class="nostrongtext margin_top">共计：{{item.total_zl_num}}种/{{item.total_goods_num}}件
					<text v-show="item.z_total_zl_num">，赠品：{{item.z_total_zl_num}}种/{{item.z_total_goods_num}}件</text>
				</view>
			</view>
		</view>
		<!-- <view class="dibubox flexcenter ffffff">
			<view class="quedingbtn" @click="guwtjsp">确认</view>
		</view> -->
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				keywords: "",
				list: [],
				getmsg: {
					type:3,//3销售单
					warehouse_id:"",
					custom_id:"",
				},
				ids: []
			}
		},
		onLoad(options) {
			let data = JSON.parse(decodeURIComponent(options.getmsg));
			this.getmsg = data
			this.getList()
		},
		methods: {
			getList() {
				httpRequest.request('/dhtapi/Saleorder/activityList', 'POST', {
					custom_id: this.getmsg.custom_id, 
				}).then(res => {
					res.data.forEach(item=>{
						this.$set(item,"is_check",false)
					})
					this.list = res.data
				})
			},
			checkgoods(item) {
				let data = {
					type:3,
					warehouse_id:this.getmsg.warehouse_id,
					id:item.id
				}
				uni.navigateTo({
					url: '/pages/workbench/xiaoshou/tianjiazpsp?getmsg=' + encodeURIComponent(JSON.stringify(data))
				})
			},
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			guwtjsp() {
				let data = {
					type:3,
					ids:[]
				}
				this.list.forEach(item=>{
					if(item.is_check){
						data.ids.push(item.id)
					}
				})
				if(data.ids.length==0){
					httpRequest.toast("请选择促销商品")
					return false
				}
				data.ids = data.ids.join()
				uni.navigateTo({
					url: '/pages/workbench/xiaoshou/tianjiazpsp?getmsg=' + encodeURIComponent(JSON.stringify(data))
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.Vector {
		background-image: url('@/static/image/system/Vector.png');
		width: 40rpx !important;
		height: 40rpx !important;
		background-size: 100% 100%;
	}
	
	.Vectorhuse {
		background-image: url('@/static/image/system/Vectorkong.png');
		width: 40rpx !important;
		height: 40rpx !important;
		background-size: 100% 100%;
	}
	.xuanzebtn {
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0BBDCB;
		width: 86rpx;
		height: 40rpx;
		background: rgba(11, 189, 203, .1);
		border-radius: 134rpx;
	}

	.input-text {
		width: 588rpx;
		padding: 18rpx 0 18rpx 32rpx;
		background: rgba(153, 153, 153, .1);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.sousuo {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0BBDCB;
	}

	// 顶部自定义
	.header-top-box {
		height: 170rpx;
		width: 100%;
	}

	.header-top {
		width: 100%;
		box-sizing: border-box;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 2;
		background-color: #fff;
		padding: 96rpx 40rpx 10rpx;
	}

	.top-image {
		margin-top: 20rpx;
		width: 20rpx;
		height: 38rpx;
		background: url('@/static/image/system/return.png') no-repeat;
		background-size: 20rpx 38rpx;
	}

	// 自定义顶部搜索
	.searchinput {
		margin-top: 20rpx;
		background-color: #f7f7f7;
		border-radius: 50rpx;
		padding: 12rpx 20rpx;

		input {
			width: 100%;
		}
	}

	.searchimg {
		width: 34rpx;
		height: 34rpx;
		background-image: url("@/static/image/system/search.png");
		background-size: 100% 100%;
		margin-right: 30rpx;
	}

	.dibubox {
		padding: 30rpx 30rpx 70rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		box-sizing: border-box;
	}

	.gouwuche {
		background-image: url('@/static/image/system/gouwuche.png');
		width: 44rpx;
		height: 44rpx;
		background-size: 100% 100%;
	}

	.huisetext {
		font-size: 20rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.zengpin {
		margin-right: 20rpx;
	}

	.dhh {
		background-image: url('@/static/image/system/dhh.png');
		width: 34rpx;
		height: 34rpx;
		margin: auto;
		background-size: 100% 100%;
	}

	.xiaotext {
		font-size: 18rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.zp {
		background-image: url('@/static/image/system/zp.png');
		width: 34rpx;
		margin: auto;
		height: 34rpx;
		background-size: 100% 100%;
	}

	.gouwuche {
		background-image: url('@/static/image/system/gouwuche.png');
		width: 44rpx;
		height: 44rpx;
		background-size: 100% 100%;
	}

	.huisetext {
		font-size: 20rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.Vector {
		background-image: url('@/static/image/system/Vector.png');
		width: 25rpx;
		height: 25rpx;
		background-size: 100% 100%;
	}

	.Vectorhuse {
		background-image: url('@/static/image/system/Vectorkong.png');
		width: 25rpx;
		height: 25rpx;
		background-size: 100% 100%;
	}

	.rightitem {
		border-bottom: 2rpx solid #f7f7f7;
	}

	.quedingbtn {
		width: 100%;
		padding: 20rpx 0;
		font-size: 32rpx;
		background-color: #00B855;
		border-radius: 41rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.teshupadding {
		padding: 30rpx 30rpx 176rpx;
	}
</style>